package com.liruan.rest;

import java.io.IOException;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

/**
 * <h1>WEB服务器启动类
 * <h1>
 * 
 * @author hao.wang
 */
@SpringBootApplication(scanBasePackages = {"com.liruan.rest.aop", "com.liruan.rest.controller", "com.liruan.rest.service", "com.liruan.rest.apimangement"})
@MapperScan(basePackages = {"com.liruan.rest.dao"})
@EnableTransactionManagement
public class WebStarter extends SpringBootServletInitializer
{
	@Bean
	public ObjectMapper objectMapper()
	{
		return new ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS).setSerializationInclusion(Include.NON_NULL).disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
	}

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
	{
		return application.sources(WebStarter.class);
	}

	public static void main(String[] args) throws IOException
	{
		SpringApplication.run(WebStarter.class, args);
	}

}
